package org.seven.jrdp.biz.sys.service;

import java.util.Map;

import org.seven.jrdp.biz.sys.mapper.SysUkeyMapper;
import org.seven.jrdp.biz.sys.model.SysUkey;
import org.seven.jrdp.commons.mybatis.model.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class SysUkeyService {
	@Autowired
	private SysUkeyMapper sysUkeyMapper;

	@Transactional(readOnly = true)
	public PageInfo<Map<String, Object>> find(Map<String, Object> map, PageRequest pageRequest) {
		PageHelper.startPage(pageRequest.getPage(), pageRequest.getRows());
		return new PageInfo<Map<String, Object>>(sysUkeyMapper.find(map));
	}

	@Transactional(readOnly = true)
	public SysUkey get(String id) {
		return sysUkeyMapper.selectByPrimaryKey(id);
	}

	@Transactional
	public void insert(SysUkey sysUkey) {
		delete(sysUkey.getId());
		sysUkeyMapper.insertSelective(sysUkey);
	}

	@Transactional
	public void delete(String id) {
		sysUkeyMapper.deleteByPrimaryKey(id);
	}

	@Transactional(readOnly = true)
	public SysUkey getByAccount(String account) {
		return sysUkeyMapper.getByAccount(account);
	}
}